package interview.test;

import org.junit.Test;

import java.util.BitSet;

/**
 * Created with IntelliJ IDEA.
 * User: xinlyu
 * Date: 1/20/14
 * Time: 3:38 PM
 * To change this template use File | Settings | File Templates.
 */
public class NumberCanBeTwoDivide {
    private static final int TESTNUMBER = 2;
    @Test
    public void testIfCanBeDevide(){
        Integer result = null;
        Integer testData = new Integer(TESTNUMBER);
        while(result!=null){
            if(testData==2){
                result=1;
            }
            if(testData==1){
                result=0;
            }
            if(testData%2!=0){
                result =0;
            }
            testData = testData/2 ;
        }

    }

    @Test
    public void testIfCanBeDeviceInDec(){
        int count = 0;
        Integer testData = new Integer(TESTNUMBER);
        Boolean isEnd = false;
        while(!isEnd){
            if(testData - (testData>>1)==1){
               count ++;
            }
            if(count>1){
                isEnd = true;
            }
        }
        System.out.println(count>1);
    }
}
